<?php

/**
 * default actions.
 *
 * @package    mgd
 * @subpackage default
 * @author     ITMHouse
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class defaultActions extends sfActions
{
    public function executeIndex(sfWebRequest $request)
    {

    }
    
    public function executeLogin( sfWebRequest $request )
    {
        if( $request->hasParameter('username') && $request->hasParameter('password') )
        {
            if( $oAdmin = $this->getUser()->login( $request->getPostParameter('username'), $request->getPostParameter('password'), (bool) $request->getPostParameter('remember') ) )
            {                                                             
                if ($oAdmin->getAdminFlag())
                {
                    $this->getUser()->addCredential('admin');                    
                }
                
                $this->redirect('@homepage');   
            }
            
            $this->getUser()->setFlash('error', 'Неверный логин или пароль.', false);
        }
        
        $this->setLayout('layoutAuth');        
    }
    
    public function executeLogout( sfWebRequest $request )
    {
        $this->getUser()->clearCredentials();
        $this->getUser()->logout(); 
        $this->redirect('@login');
    }
    
    public function executeSecure()
    {
        
    }
}
